package com.example.consumer.controller;
import com.example.consumer.ProviderFeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
 * 类描述：调用服务类
 * 
 * @author xhy
 * @date 2025/9/25 11:35
 * @version 1.0.0
 */
@RestController
public class ConsumerController {
    @Resource  // 或 @Autowired，推荐 @Resource 更灵活
    private ProviderFeignClient providerFeignClient;

    // 消费者对外提供的接口：调用提供者的 /user/{id}
    @GetMapping("/call/provider/{id}")
    public String callProvider(@PathVariable String id) {
        // 通过 Feign 客户端调用 provider-demo 服务的接口
        String result = providerFeignClient.getUserInfo(id);
        return "Consumer 调用结果：" + result;
    }
}
